﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Needle.Core;
using Needle.Core.Lifetime;

namespace Needle.Simulation.Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            var kernel = new Kernel();

            kernel.RegisterInstance<PermanentAttribute, int>(16, "InitialFloor");
            kernel.RegisterInstance<PermanentAttribute, bool>(false, "InitialDoorState");
            kernel.RegisterInstance<PermanentAttribute, Direction>(Direction.Up, "InitialDirection");
            kernel.RegisterInstance<PermanentAttribute, TimeSpan>(TimeSpan.FromMinutes(60), "MaxRunTime");

            using (Simulation sim = kernel.GetInstance<Simulation>())
            {
                sim.DebugOutput = true;

                var ticker = new Ticker(TimeSpan.FromSeconds(1));
                var tocker = new Tocker();
                var buttons = kernel.GetInstance<Buttons>();
                var elevator = kernel.GetInstance<Elevator>();
                sim.StartProcess(ticker);
                sim.StartProcess(tocker);
                sim.StartProcess(elevator);
                sim.StartProcess(buttons);
                sim.Run();
            }
            Console.WriteLine("Press <enter> to exit.");
            Console.ReadLine();
        }
    }
}
